﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DetailViewStudy
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack == false)
            {
                this.BindData();
            }
        }

        private void BindData()
        {
            List<Person> persons = new List<Person>();
            persons.Add(new Person("zhangsan",20));
            persons.Add(new Person("lisi", 21));

            this.DetailsView1.DataSource = persons;
            this.DetailsView1.DataBind();
        }


        protected void DetailsView1_ItemCreated(object sender, EventArgs e)
        {
            
            if (this.IsPostBack)
            {
                DetailsView detailsView = (DetailsView)sender;
                if (detailsView.CurrentMode == DetailsViewMode.Edit)
                {
                    Label Label1 = (Label)detailsView.FindControl("Label1");
                    if (Label1 != null)
                    {
                        Label1.Text = "ssssss";
                    }
                }

               
            }


        }

        protected void DetailsView1_ModeChanging(object sender, DetailsViewModeEventArgs e)
        {
            e.NewMode = DetailsViewMode.Edit;
            //if (e.NewMode == DetailsViewMode.Edit)
            //{
            //    DetailsView1.mode = DetailsViewMode.Edit;
            //}
        }

        protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
        {

        }
    }
}